{% extends "base.html" %}
{% load i18n %}
{% block title %} Tu Negocio Empresarios - Ver Notas Cliente {% endblock %}

{% block head-css-ext %}
	<link rel="stylesheet" type="text/css" href="{{MEDIA_URL}}css/layout.css" media="screen" />
	<link rel="stylesheet" type="text/css" href="{{MEDIA_URL}}css/jquery-ui.css" media="screen" />
	<link rel="stylesheet" type="text/css" href="{{MEDIA_URL}}css/blue/style.css" media="print, projection, screen" />
{% endblock %}

{% block head-js-ext %}
	<script type="text/javascript" src="{{MEDIA_URL}}js/jquery.js"></script>
	<script type="text/javascript" src="{{MEDIA_URL}}js/jquery-ui.js"></script>
	<script type="text/javascript" src="{{MEDIA_URL}}js/jquery.tablesorter.js"></script>
	<script type="text/javascript" src="{{MEDIA_URL}}js/jquery.tablePagination.js"></script>
	<script type="text/javascript" src="{{MEDIA_URL}}js/jquery.translate.js"></script>  
{% endblock %}

{% block head-js-embedded %}
	<script type="text/javascript">
        $(document).ready(function(){
            var options = {
                firstArrow : (new Image()).src="{{MEDIA_URL}}img/icons/first.png",
                prevArrow : (new Image()).src="{{MEDIA_URL}}img/icons/prev.png",
                lastArrow : (new Image()).src="{{MEDIA_URL}}img/icons/last.png",
                nextArrow : (new Image()).src="{{MEDIA_URL}}img/icons/next.png"
            }	  
            $("#notas")
              .tablesorter({widthFixed: true,  widgets: ['zebra'], headers: { 2 : {sorter: false}, 3 : {sorter: false}, 4 : {sorter: false}, 5 : {sorter: false} } })
              .tablePagination(options);
            
            $("#tablePagination").translate('en', 'es');
      
            $("input:submit", ".enviar").button();
      
            $("#checkall").click(function(){
                var checked_status = this.checked;
                $("input[id=event]").each(function(){
                    this.checked = checked_status;
                });
            });
            
            $("form").submit(function(){
                if (!isCheckedById("event"))
                {
                    alert ("Seleccione al menos una Nota");
                    return false;
                }
                else
                {
                    return true; //submit the form
                }
            });
      
            function isCheckedById(id)
            {
                var checked = $("input[id="+id+"]:checked").length;
                if (checked == 0)
                {
                    return false;
                }
                else
                {
                    return true;
                }
            }
        });        
    </script>
{% endblock %}
{% block content-box1 %}
    <b>Notas Cliente: {{ cliente }}</b>
    {% if notas %}  
        <form action="" method="POST">{% csrf_token %}
            <div align="right">
                <label for="checkall"><b>Seleccionar Todas</b></label>
                <input type=checkbox id="checkall" name="checkall" />
            </div>
            <table id="notas" class="tablesorter">
                <thead>
                    <tr align="center">
                        <th>Fecha&nbsp;&nbsp;</th>
                        <th>Asunto&nbsp;&nbsp;</th>
                        <th>Contenido</th>
                        <th>Eliminar Nota</th>               
                    </tr>            
                </thead>
                <tbody>
                    {% for nota in notas %}
                        <tr align="center">
                            <td>{{ nota.fecha|date:"d M Y"  }}</td>
                            <td>{{ nota.asunto }}</td>
                            <td>{{ nota.contenido }}</td>
                            <td><input type="checkbox" name="elinar_nota" value="{{ nota.id }}" id="event"></td>
                        </tr>
                    {% endfor %}
                </tbody>
            </table>
            <br>
            <div align="center" class="enviar">
                <input type="submit" name="eliminarnotas" value="Eliminar Notas">
            </div>
        </form>
    {% else %}
        <p><b>No tiene anotaciones para este cliente</b></p>
    {% endif %}
{% endblock %}
{% block content-colum2 %}
    {% if user.is_authenticated %}
        <ul>
            <li><a href="{% url index %}">{% trans "Home" %}</a></li>
            <li><a href="{% url clientes %}">Clientes</a></li>      
            <li><a href="{% url listar_clientes %}">Listar Clientes</a></li>
            <li><a href="{% url agregar_nota_cliente cliente.codigo %}">Agregar Nota Cliente</a></li>	
        </ul>
    {% endif %}   
{% endblock %}